﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using DTO;
using BUS;

namespace MasterPageGroupF3.ho_chi_minh
{
    public partial class DanhSachDonDatHang : System.Web.UI.Page
    {
        private Object list;
        protected void Page_Load(object sender, EventArgs e)
        {
            Session["idCity"] = 2;
            if (Request.QueryString["logout"] != null)
            {
                if (Request.QueryString["logout"].ToString().Equals("true"))
                {
                    Session.Remove("UserName");
                    Session.Remove("Provider");
                }
            }
            // phan sua giao dien
            if (Session["Provider"] != null)
            {
                Label lbTaiKhoan = (Label)this.Master.FindControl("lbTaiKhoan");
                lbTaiKhoan.Text = Session["Provider"].ToString();
                Label lbLogout = (Label)this.Master.FindControl("lbLogout");
                lbLogout.Text = "<li><img src=\"../skin/frontend/default/inspire-blue/images/citydivider.jpg\"/></li>" +
                    "<li class=\"first\"><a href=\"index.aspx?logout=true\">Thoát</a></li>";
                Label lbDangKy = (Label)this.Master.FindControl("lbDangKy");
                lbDangKy.Text = "";

                string username = Session["Provider"].ToString();
                PROVIDER temp = PROVIDERBUS.LayProviderCoUser(username);                
                list = PROVIDERBUS.DoanhThuSanPhamTheoProvider(temp.IDPROVIDER); 
            }  


           // String username = (String)Session["Provider"];
           // PROVIDER prvd = PROVIDERBUS.LayProviderCoUser(username);
           // //// dang test
           // PRODUCT[] prolist = PROVIDERBUS.LayDSProduct(prvd.IDPROVIDER );
           // int i =1;
           //// int tongsodondathang=0;
           // foreach (PRODUCT pro in prolist)
           // {
           //     LinqDataSource1.Where += "IDPRODUCT == " + pro.IDPRODUCT;
           //     int len = prolist.Length;
           //     if ( len > i)
           //     {
           //         LinqDataSource1.Where += " or ";
           //     }
           //     i++;
           // }
                       
            if (!IsPostBack)
            {
                GridView1.DataSource = list;
                GridView1.DataBind();                
            }
        }

        protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
        {
            GridView1.PageIndex = e.NewPageIndex;
            GridView1.DataSource = list;
            GridView1.DataBind();
        }
    }
}